include( 'shared.lua' )


// Clientside only stuff goes here

RunConsoleCommand("hud_deathnotice_time", "0")

//Disable those HUDs for more realism
local blockedHuds = {"CHudHealth", "CHudBattery", "CHudCrosshair", "CHudWeaponSelection", "CHudDamageIndicator", "CHudAmmo"}

function GM:HUDShouldDraw( n )

	for k, v in pairs(blockedHuds) do
	
		if (v == n) then
		
			return false
			
		end
	
	end
	
	return true

end

function GM:HUDDrawScoreBoard()

end

function GM:HUDPaint()

end

function GM:PostProcessPermitted(element)

	return false
	
end


function GM:RenderScreenspaceEffects()

	local ply = LocalPlayer()
	
	local tab= {}
	tab[ "$pp_colour_addr" ] 		= 0
	tab[ "$pp_colour_addg" ] 		= 0
	tab[ "$pp_colour_addb" ] 		= 0
	tab[ "$pp_colour_brightness" ] 	 = -3/ply:Health()
	tab[ "$pp_colour_contrast" ] 	 	= 1
	tab[ "$pp_colour_colour" ] 		= 1
	tab[ "$pp_colour_mulr" ] 		= 0
	tab[ "$pp_colour_mulg" ] 		= 0
	tab[ "$pp_colour_mulb" ] 		= 0	
	
	if (ply:GetNWInt("hunger") < 5) then
	
		DrawMotionBlur( 0.1, 0.79, 0.05 )
				
	end
	
	if (ply:IsDying()) then
	
		tab[ "$pp_colour_brightness" ] 	 = -3/ply:Health()

		DrawColorModify( tab )

	elseif (!ply:Alive()) then
	
		tab[ "$pp_colour_brightness" ] 	 = -1
		
		DrawColorModify( tab )	
	
	end
	
end


local WalkTimer = 0
local VelSmooth = 0
local LastStrafeRoll = 0

//from Garry's GMDM
function GM:CalcView( ply, origin, angle, fov )

	local vel = ply:GetVelocity()
	local ang = ply:EyeAngles()

	VelSmooth = math.Clamp( VelSmooth * 0.9 + vel:Length() * 0.1, 0, 700 )
	
	WalkTimer = WalkTimer + VelSmooth * FrameTime() * 0.05
	
	// Roll on strafe (smoothed)
	LastStrafeRoll = (LastStrafeRoll * 3) + (ang:Right():DotProduct( vel ) * 0.0001 * VelSmooth * 0.3)
	LastStrafeRoll = LastStrafeRoll * 0.25
	angle.roll = angle.roll + LastStrafeRoll
	

	// Roll on steps
	if ( ply:GetGroundEntity() != NULL ) then	
	
		angle.roll = angle.roll + math.sin( WalkTimer ) * VelSmooth * 0.000002 * VelSmooth
		angle.pitch = angle.pitch + math.cos( WalkTimer * 0.5 ) * VelSmooth * 0.000002 * VelSmooth
		angle.yaw = angle.yaw + math.cos( WalkTimer ) * VelSmooth * 0.000002 * VelSmooth
		
	end
	
	angle = angle
	
	fov = fov - 10
		
	return self.BaseClass:CalcView( ply, origin, angle, fov )

end